<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/common_setting_unit.php"); ?>

<?php include_once("../controller/term-list.php"); ?>






<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <?php include_once('../../../modules/head.php'); ?>
    <link href="../assets/css/style.css" rel="stylesheet" type="text/css"/>
</head>











<body>

<div id="topbar">
    <?php include '../../../modules/topbar.php'; ?>
</div>


<div id="container">
<!--Container端點01-->
    <div id="maincontent" class="term-list">
<!--maincontent端點01-->



        <div id="sidebar">
            <?php include '../../../modules/sidebar.php'; ?>
        </div>




<div id="content">

    <!--标题设定-->
    <?php $page_title=$_plate['name'].'列表';?>
    <?php include ROOT_PATH_ . '/controller/common/module/mod-page-title.php'; ?>



    <div class="select-box layui-form clearfix brand">
        <form action="term-list.php" >

            <div class="layui-form-item">
                <label class="layui-form-label">关键词</label>
                <div class="layui-input-block">
                    <input type="text"  name="select_keywords" placeholder="品牌名称" autocomplete="off" class="layui-input" value="<? echo $_REQUEST['select_keywords']?>" >
                </div>
            </div>


            <input type="hidden"  name="sys_part"  value="<?php echo $system_part;?>"/>
            <button class="layui-btn" ><i class="layui-icon">&#xe615;</i> 查找</button>

            <a class="layui-btn" href="term-list.php?sys_part=brand"><i class="layui-icon">&#x1006;</i> 重置</a>

            <br class="clearfloat"/>
        </form>

        <br class="clearfloat"/>
    </div>



<div class="list-box <? echo $system_part ?>">



    <hr/>
    <div class="statistic">
        <?php include_once("../modules/term_btn.php");?>

<!--        <div class="function">-->
<!---->
<!--            <div class="sort layui-form">-->
<!--                <div class="layui-form-item" style="margin-bottom:5px;">-->
<!--                    <label class="layui-form-label">排序：</label>-->
<!--                    <div class="layui-input-block">-->
<!--                        <select lay-filter="MM_jumpMenu">-->
<!--                            <option value="">排序选择</option>-->
<!--                            <option value="term-list.php?nowpageid=--><?php //echo $nowpageid; ?><!--&sortby=listorder&&sortorder=desc&sys_part=--><?// echo $system_part ?><!--">人工排序降序</option>-->
<!--                            <option value="term-list.php?nowpageid=--><?php //echo $nowpageid; ?><!--&sortby=listorder&&sortorder=asc&sys_part=--><?// echo $system_part ?><!--">人工排序升序</option>-->
<!--                            <option value="term-list.php?nowpageid=--><?php //echo $nowpageid; ?><!--&sortby=nid&&sortorder=desc&sys_part=--><?// echo $system_part ?><!--">输入时间降序</option>-->
<!--                            <option value="term-list.php?nowpageid=--><?php //echo $nowpageid; ?><!--&sortby=nid&&sortorder=asc&sys_part=--><?// echo $system_part ?><!--">输入时间升序</option>-->
<!--                            <option value="term-list.php?nowpageid=--><?php //echo $nowpageid; ?><!--&sortby=name&&sortorder=desc&sys_part=--><?// echo $system_part ?><!--">资料名称升序</option>-->
<!--                            <option value="term-list.php?nowpageid=--><?php //echo $nowpageid; ?><!--&sortby=name&&sortorder=asc&sys_part=--><?// echo $system_part ?><!--">资料名称降序</option>-->
<!--                        </select>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!---->
<!---->
<!--        </div>-->


        <hr/>
    </div>




<div class="list-boxes term-list-box">


    <table class="layui-table  layui-form">
        <colgroup>

            <col  width="60">
            <col  width="60">
            <col >
            <col  width="200">
            <col  width="200">
            <col  width="200">
            <col >
            <col width="190">

        </colgroup>
        <thead>
        <tr>

            <th>序号</th>
            <th>品牌标志</th>
            <th>品牌名称</th>
            <th>排序</th>
            <th>状态</th>
            <th>发布</th>
            <th>产品数量</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>


        <?php

        if (!$root_term_list) {
            echo "<tr><td colspan='4'>暂无数据</td></tr>";
        }


        foreach($root_term_list as $key=>$detail){
            $number=0;
            $term_number=0;
            //查看有没有这个分类的子分类
            $pt['condition'] = ' term_nid ='.$detail['nid'];
            $pt['item'] = 'nid';
            $pt['table'] = $table_Prefix . "relation";
            $term_number = count_number($pt);
            ?>

            <tr id="item<?echo $detail['nid']?>" >
                <td><?echo $key + 1 ?></td>
                <td>
                    <div class="icon-box" style="background: url('/uploadfiles/<?echo $theme_folder?>/<? echo $detail['icon']?>')"></div>
                </td>
                <td><span class="layui-badge layui-bg-green">品牌</span> <b><? echo $detail['en_name']?> (<? echo $detail['name']?>)</b></td>



                <td>
                    <li class="listorder bind-listorder">
                        <div class="addsub">
                            <div class="title">列表顺序</div>
                            <button type="button" class="btn-add">
                                +
                            </button>
                            <input type="text" data-id="<?echo $detail['nid']?>"   class="input-counter" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $detail['listorder'] ?>">
                            <button type="button" class="btn-subtract">
                                -
                            </button>
                        </div>


                    </li>

                    <li class="markorder bind-markorder" style="display:none">

                        <div class="addsub">
                            <div class="title">标记顺序</div>
                            <button type="button" class="btn-add">
                                +
                            </button>
                            <input type="text" class="input-counter" data-id="<?echo $detail['nid']?>" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $detail['markorder'] ?>">
                            <button type="button" class="btn-subtract">
                                -
                            </button>
                        </div>

                    </li>



                </td>


                <td class="mark">
                    <label>标记状态</label>
                    <input type="checkbox" name="term_mark" value="<?php echo $detail['mark'];?>"
                           lay-skin="switch" lay-filter="filter"
                           id="<?php echo $detail['nid'];?>"
                           lay-text="是|否" <?if ($detail['mark'] == 1) { echo "checked"; }?> >
                </td>


                <td class="publish">
                    <input type="checkbox" name="term_publish" value="<?php echo $detail['publish'];?>"
                           lay-skin="switch" lay-filter="filter"
                           id="<?php echo $detail['nid'];?>"
                           lay-text="是|否" <?if ($detail['publish'] == 1) { echo "checked"; }?> >



                </td>


                <td><?echo $term_number?></td>


                <td>
                    <a href="term-edit.php?nid=<?php echo $detail['nid']?>&sys_part=<?echo $_REQUEST['sys_part']?>"
                       class=" layui-btn  layui-btn-sm" >
                        <i class="fa fa-eye" aria-hidden="true"></i>编辑</a>
                    <?php
                    if(($number+$term_number) ==0){
                        ?>

                        <a href="javascript:void(0)"
                           class="delete layui-btn  layui-btn-sm"
                           <?php
                           if($detail_is_disabled[$i] == 1){echo 'style= background:#ccc;cursor:not-allowed;';}
                           else{ echo 'onclick="delete_term('. $detail['nid'].' )"';}?> > <i class="layui-icon">&#xe640;</i> 删除
                        </a>


                    <?php }
                    else { ?>

                        <span class="delete layui-btn  layui-btn-sm"
                              style="background:#ccc;cursor:not-allowed;">
                             <i class="layui-icon">&#xe640;</i> 关联中
                        </span>
                    <?}
                    ?>
                </td>
            </tr>




            <?php foreach($term_list as $k2=>$v2){
                if($detail['nid']==$v2['term1']){
                    $number=0;
                    //查看有没有这个分类的产品
                    $p_where['condition'] = ' term_nid ='.$v2['nid'];
                    $p_where['condition'] = ' term_nid ='.$v2['nid'];
                    $p_where['item'] = 'nid';
                    $p_where['table'] = $table_Prefix . "relation";
                    $number = count_number($p_where);

                    ?>

                    <tr  id="item<?echo $v2['nid']?>" >
                        <td> </td>
                        <td>
                             <div class="icon-box" style="background: url('/uploadfiles/<?echo $theme_folder?>/<? echo $v2['icon']?>')"></div>
                        </td>
                        <td><span class="layui-badge layui-bg-orange">系列</span>  <? echo $v2['name']?> </td>
                        <td>
                            <li class="listorder bind-listorder">
                                <div class="addsub">
                                    <div class="title">列表顺序</div>
                                    <button type="button" class="btn-add">
                                        +
                                    </button>
                                    <input type="text" data-id="<?echo $v2['nid']?>"   class="input-counter" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $v2['listorder'] ?>">
                                    <button type="button" class="btn-subtract">
                                        -
                                    </button>
                                </div>
                            </li>

                            <li class="markorder bind-markorder" style="display:none">

                                <div class="addsub">
                                    <div class="title">标记顺序</div>
                                    <button type="button" class="btn-add">
                                        +
                                    </button>
                                    <input type="text" class="input-counter" data-id="<?echo $detail['nid']?>" oninput="value=value.replace(/[^\d]/g,'')" value="<? echo $detail['markorder'] ?>">
                                    <button type="button" class="btn-subtract">
                                        -
                                    </button>
                                </div>

                            </li>
                        </td>


                        <td class="mark">
                            <label>标记状态</label>
                            <input type="checkbox" name="term_mark" value="<?php echo $v2['mark'];?>"
                                   lay-skin="switch" lay-filter="filter"
                                   id="<?php echo $v2['nid'];?>"
                                   lay-text="是|否" <?if ($v2['mark'] == 1) { echo "checked"; }?> >
                        </td>


                        <td class="publish">
                            <input type="checkbox" name="term_publish" value="<?php echo $detail['publish'];?>"
                                   lay-skin="switch" lay-filter="filter"
                                   id="<?php echo $v2['nid'];?>"
                                   lay-text="是|否" <?if ($v2['publish'] == 1) { echo "checked"; }?> >
                        </td>

                        <td><? echo $number?></td>


                        <td>
                            <a href="term-edit.php?nid=<?php echo $v2['nid']?>&sys_part=<?echo $_REQUEST['sys_part']?>"
                               class=" layui-btn  layui-btn-sm" >
                                <i class="fa fa-eye" aria-hidden="true"></i>编辑</a>
                            <?php
                            if($number ==0){
                                ?>
                                <a href="javascript:void(0)"  class="delete layui-btn  layui-btn-sm"
                                    <?php if($detail_is_disabled[$i] == 1){echo 'style= background:#ccc;cursor:not-allowed;';}
                                    else{ echo 'onclick="delete_term('. $v2['nid'].' )"';}?> > <i class="layui-icon">&#xe640;</i> 删除</a>
                            <?php }
                            else { ?>

                                <span class="delete layui-btn  layui-btn-sm"
                                      style="background:#ccc;cursor:not-allowed;">
                             <i class="layui-icon">&#xe640;</i> 关联中
                        </span>
                            <?}?>
                        </td>
                    </tr>
                <?}?>
                <?php;}?>



            <?php

        }
        ?>
        </tbody>
    </table>

</div>





<?php include 'modules/page_numbers_brand.php'; ?>




<!--list-box end-->
</div>

<!--content端點01-->
</div>

<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>

<!--删除box-->
<?php include '../modules/deletebar.php'; ?>
<!--删除box end-->
<?php include  ROOT_PATH_."/controller/common/module/footer.php"; ?>
<script src="../assets/js/list-update.js"></script>
<script src="../assets/js/term_delete.js"></script>

</body>
</html>
